package org.wlw.exception;

public class TestException02 {
    public static void main(String[] args) {
        try{
            fn1(33,null);
        } catch (NullPointerException e) {
            System.out.println(e.getMessage());
        }

        System.out.println("程序结束");
    }

    public static void fn1(int b,String str) {
        try {
            int a = 10;
            System.out.println(str.length());
            System.out.println(a/b);
        } catch (ArithmeticException e) {
            System.out.println("发现了数学运算异常");
        } catch (Exception e) {
//            e.printStackTrace();
            System.out.println("发现错误:"+e.getMessage());
            throw e;//把对象抛出，注意抛出的是对象
        }
    }
}
